package com.example.demo.common;

import java.io.PrintWriter;
import java.io.StringWriter;

import com.example.demo.controller.BookController;

import lombok.extern.log4j.Log4j2;

@Log4j2
public class ErrorUtils {
	/**
	 * 获取错误的堆栈信息
	 * @param throwable
	 * @return
	 */
	public static String getStackTrace(Throwable throwable){
		StringWriter stringWriter=new StringWriter();
		PrintWriter printWriter=new PrintWriter(stringWriter);

		try {
			throwable.printStackTrace(printWriter);
			return stringWriter.toString();
		}
		finally {
			printWriter.close();
		}

	}
}
